﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
using System.Threading;

namespace SCI_actuator
{
    public partial class Robot : Form
    {
        private menu_control frmain;
        private System.Timers.Timer robot_time;

        private bool move1_start;
        private bool move2_start;
        public Robot(menu_control fr)
        {
            InitializeComponent();
            this.frmain = fr;

            move1_start = false;
            move2_start = false;

            robot_time = new System.Timers.Timer();
            robot_time.Interval = 500;
            robot_time.Enabled = Enabled;
            robot_time.Stop();
            robot_time.Elapsed += new ElapsedEventHandler(RobotTime_tick);        
        }
        private void Delay_ms(int mm)
        {
            DateTime current = DateTime.Now;

            while (current.AddMilliseconds(mm) > DateTime.Now)
            {
                Application.DoEvents();
            }
            return;
        }
        private void Robot_readyBtn_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21"    //计算检验和
                + "01" + "02" + constant.REG_ACTION + "01"
                + "02" + "02" + constant.REG_ACTION + "01"
                + "03" + "02" + constant.REG_ACTION + "01"
                + "04" + "02" + constant.REG_ACTION + "01"
                + "05" + "02" + constant.REG_ACTION + "01"
                + "06" + "02" + constant.REG_ACTION + "01"
                + "07" + "02" + constant.REG_ACTION + "01"
                + "08" + "02" + constant.REG_ACTION + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            string senddata = "FF" + "FF" + "FE" + "21" 
                + "01" + "02" + constant.REG_ACTION + "01"
                + "02" + "02" + constant.REG_ACTION + "01"
                + "03" + "02" + constant.REG_ACTION + "01"
                + "04" + "02" + constant.REG_ACTION + "01"
                + "05" + "02" + constant.REG_ACTION + "01"
                + "06" + "02" + constant.REG_ACTION + "01"
                + "07" + "02" + constant.REG_ACTION + "01"
                + "08" + "02" + constant.REG_ACTION + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
            Delay_ms(100);

            bRx = this.frmain.HexStringToByteArray("FE" + "31"           //实时曲线
                + "01" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "02" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "03" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "04" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "05" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "06" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "07" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "08" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40");
            sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            senddata = "FF" + "FF" + "FE" + "31" 
                + "01" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "02" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "03" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "04" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "05" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "06" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40"
                + "07" + "04" + constant.REG_SEEK_POSITION_HI + "01" + constant.REG_SEEK_POSITION_LO + "00"
                + "08" + "04" + constant.REG_SEEK_POSITION_HI + "02" + constant.REG_SEEK_POSITION_LO + "40" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();

            }
            this.frmain.servosend(senddata);
            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void Robot_brakeBtn_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            string curve = null;
            robot_time.Stop();

            move1_start = false;
            move2_start = false;

            byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void RobotTime_tick(object sender, ElapsedEventArgs e)
        {
            string sum_str = null;
            string unstop = null;

            if (this.frmain.group_counter == 0)
            {
                if (this.frmain.unstop_counter == 0)
                {
                    byte[] bRx = this.frmain.HexStringToByteArray("FE" + "31" 
                         + "01" + "0A" + constant.REG_T_POSITION_HI + "02"+ constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02" 
                         + "03" + "0A" + constant.REG_T_POSITION_HI + "02"+ constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02" 
                         + "05" + "0A" + constant.REG_T_POSITION_HI + "02"+ constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02" 
                         + "07" + "0A" + constant.REG_T_POSITION_HI + "02"+ constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02");
                    byte sum = this.frmain.checksum(bRx);
                    if (sum >= 16)
                        sum_str = Convert.ToString(sum, 16);
                    else
                        sum_str = "0" + Convert.ToString(sum, 16);
                    unstop = "FF" + "FF" + "FE" + "31"
                         + "01" + "0A" + constant.REG_T_POSITION_HI + "02" + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02"
                         + "03" + "0A" + constant.REG_T_POSITION_HI + "02" + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02"
                         + "05" + "0A" + constant.REG_T_POSITION_HI + "02" + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02"
                         + "07" + "0A" + constant.REG_T_POSITION_HI + "02" + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO + "40" + constant.REG_CURVE_APPEND + "02"
                         + sum_str;
                    ++this.frmain.unstop_counter;
                }
                else if (this.frmain.unstop_counter == 1)
                {
                    byte[] bRx = this.frmain.HexStringToByteArray("FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02");
                    byte sum = this.frmain.checksum(bRx);
                    if (sum >= 16)
                        sum_str = Convert.ToString(sum, 16);
                    else
                        sum_str = "0" + Convert.ToString(sum, 16);
                    unstop = "FF" + "FF" + "FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "03"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "E0" + constant.REG_CURVE_APPEND + "02" + sum_str;

                    ++this.frmain.unstop_counter;
                }
                else if (this.frmain.unstop_counter == 2)
                {
                    byte[] bRx = this.frmain.HexStringToByteArray("FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02");
                    byte sum = this.frmain.checksum(bRx);
                    if (sum >= 16)
                        sum_str = Convert.ToString(sum, 16);
                    else
                        sum_str = "0" + Convert.ToString(sum, 16);
                    unstop = "FF" + "FF" + "FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "02"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "50" + constant.REG_CURVE_APPEND + "02" + sum_str;

                    ++this.frmain.unstop_counter;
                }
                else if (this.frmain.unstop_counter == 3)
                {
                    byte[] bRx = this.frmain.HexStringToByteArray("FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02");
                    byte sum = this.frmain.checksum(bRx);
                    if (sum >= 16)
                        sum_str = Convert.ToString(sum, 16);
                    else
                        sum_str = "0" + Convert.ToString(sum, 16);
                    unstop = "FF" + "FF" + "FE" + "31" + "01" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "03" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "05" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + "07" + "0A" + constant.REG_T_POSITION_HI + "01"
                         + constant.REG_T_POSITION_LO + "40" + constant.REG_T_VELOCITY_HI + "00" + constant.REG_T_VELOCITY_LO
                         + "B0" + constant.REG_CURVE_APPEND + "02" + sum_str;

                    this.frmain.unstop_counter = 0;

                    this.frmain.group_counter = 1;
                }
            }
            else if (this.frmain.group_counter == 1)
            {
                byte[] bRx = this.frmain.HexStringToByteArray("01" + "03" + "01" + constant.REG_T_BUFFER);
                byte sum = this.frmain.checksum(bRx);
                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                unstop = "FF" + "FF" + "01" + "03" + "01" + constant.REG_T_BUFFER + sum_str;

                this.frmain.group_counter = 2;
            }
            else if (this.frmain.group_counter == 2)
            {
                byte[] bRx = this.frmain.HexStringToByteArray("01" + "03" + "01" + constant.REG_T_BUFFER);
                byte sum = this.frmain.checksum(bRx);
                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                unstop = "FF" + "FF" + "01" + "03" + "01" + constant.REG_T_BUFFER + sum_str;

                this.frmain.group_counter = 2;
            }

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }
            this.frmain.servosend(unstop);

            Delay_ms(5);

            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void Robot_walkBtn_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            string curve = null;

            move1_start = false;
            move2_start = false;

            if (Robot_walkBtn.Text == "机器人原地运动（T）")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.REG_MODEL + "01"
                + "02" + "02" + constant.REG_MODEL + "01"
                + "03" + "02" + constant.REG_MODEL + "01"
                + "04" + "02" + constant.REG_MODEL + "01"
                + "05" + "02" + constant.REG_MODEL + "01"
                + "06" + "02" + constant.REG_MODEL + "01"
                + "07" + "02" + constant.REG_MODEL + "01"
                + "08" + "02" + constant.REG_MODEL + "01");
                byte sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "21" 
                    + "01" + "02" + constant.REG_MODEL + "01"
                + "02" + "02" + constant.REG_MODEL + "01"
                + "03" + "02" + constant.REG_MODEL + "01"
                + "04" + "02" + constant.REG_MODEL + "01"
                + "05" + "02" + constant.REG_MODEL + "01"
                + "06" + "02" + constant.REG_MODEL + "01"
                + "07" + "02" + constant.REG_MODEL + "01"
                + "08" + "02" + constant.REG_MODEL + "01" + sum_str;

                Robot_walkBtn.Text = "机器人运动停止(T)";

                this.frmain.unstop_counter = 0;
                robot_time.Start();
            }
            else if (Robot_walkBtn.Text == "机器人运动停止(T)")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "11" 
                    + "01" + "02" + constant.BRAKE + "02"
                    + "03" + "02" + constant.BRAKE + "02"
                    + "05" + "02" + constant.BRAKE + "02"
                    + "07" + "02" + constant.BRAKE + "02");
                byte sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" +"FE" + "11" + "01" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02" + sum_str;
                Robot_walkBtn.Text = "机器人原地运动（T）";

                this.frmain.unstop_counter = 0;
                this.frmain.group_counter = 0;
                robot_time.Stop();
            }
            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void exit_Btn_Click(object sender, EventArgs e)
        {
            this.Hide();
            this.Dispose();
        }
        private void move1timer_function()
        {
            string sum_str = null;
            string curve = null;
            byte[] bRx;
            byte sum = 0;
            while (move1_start == true)
            {
                #region couter0
                bRx = this.frmain.HexStringToByteArray( "FE" + "61" 
                   + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                   + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                   + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "E0" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "03"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "61" + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                   + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                   + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "E0" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01"
                   + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                   + constant.REG_CURVE_APPEND + "01"
                   + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "03"
                   + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "06" + constant.REG_CURVE_DELTA_LO + "30"
                   + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(10);

                bRx = this.frmain.HexStringToByteArray("FE" + "49" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02"
                    + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "49" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02"
                    + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "03" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(1500);
                #region couter1
                bRx = this.frmain.HexStringToByteArray("FE" + "19" + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "19" + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(10);

                bRx = this.frmain.HexStringToByteArray("FE" + "13" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "13" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(800);
                #region couter2
                bRx = this.frmain.HexStringToByteArray("FE" + "19" + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "C0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "19" + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "C0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(10);

                bRx = this.frmain.HexStringToByteArray("FE" + "13" + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "13" + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(800);
                #region couter3
                bRx = this.frmain.HexStringToByteArray("FE" + "19" + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "19" + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(10);

                bRx = this.frmain.HexStringToByteArray("FE" + "13" + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "13" + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(800);
                #region couter4
                bRx = this.frmain.HexStringToByteArray("FE" + "19" + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "A0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "19" + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                    + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01"
                    + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "A0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(10);

                bRx = this.frmain.HexStringToByteArray("FE" + "13" + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "13" + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "10" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(800);
            }
        }
        private void Robot_moveBtn_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            string curve = null;
            robot_time.Stop();
            move2_start = false;
            if (Robot_moveBtn.Text == "机器人行走（H）")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" 
                    + "01" + "02" + constant.REG_MODEL + "02"
                + "02" + "02" + constant.REG_MODEL + "02"
                + "03" + "02" + constant.REG_MODEL + "02"
                + "04" + "02" + constant.REG_MODEL + "02"
                + "05" + "02" + constant.REG_MODEL + "02"
                + "06" + "02" + constant.REG_MODEL + "02"
                + "07" + "02" + constant.REG_MODEL + "02"
                + "08" + "02" + constant.REG_MODEL + "02");
                byte sum = this.frmain.checksum(bRx);                            

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.REG_MODEL + "02"
                + "02" + "02" + constant.REG_MODEL + "02"
                + "03" + "02" + constant.REG_MODEL + "02"
                + "04" + "02" + constant.REG_MODEL + "02"
                + "05" + "02" + constant.REG_MODEL + "02"
                + "06" + "02" + constant.REG_MODEL + "02"
                + "07" + "02" + constant.REG_MODEL + "02"
                + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                Robot_moveBtn.Text = "机器人停止（H）";
                move1_start = true;
                move1timer_function();

            }
            else if (Robot_moveBtn.Text == "机器人停止（H）")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02");
                byte sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02" + sum_str;
                Robot_moveBtn.Text = "机器人行走（H）";

                move1_start = false;

            }
            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void move2timer_function()
        {
            string sum_str = null;
            string curve = null;
            byte[] bRx;
            byte sum = 0;
            #region start
            bRx = this.frmain.HexStringToByteArray("FE" + "71" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "02" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "04" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "06" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "08" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02");
            sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            curve = "FF" + "FF" + "FE" + "71" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "02" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "04" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "06" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                 + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                 + "08" + "0C" + constant.REG_CURVE_POSITION_HI + "02"
                 + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "30"
                 + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
            #endregion
            Delay_ms(300);
            while(move2_start == true)
            {
                #region counter0
                bRx = this.frmain.HexStringToByteArray("FE" + "49" + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01" 
                        + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "03"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "49" + "01" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "07" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "03"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(16);

                bRx = this.frmain.HexStringToByteArray("FE" + "2D" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "2D" + "01" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "02" + "02" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "07" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(1500);
                #region counter1
                bRx = this.frmain.HexStringToByteArray("FE" + "49" + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01" 
                        + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01" 
                        + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "49" + "02" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "D0" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "03" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "04" + "0A" + constant.REG_CURVE_POSITION_HI + "01"
                        + constant.REG_CURVE_POSITION_LO + "50" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "05" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "06" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "70" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01"
                        + "08" + "0A" + constant.REG_CURVE_POSITION_HI + "02"
                        + constant.REG_CURVE_POSITION_LO + "00" + constant.REG_CURVE_DELTA_HI + "04" + constant.REG_CURVE_DELTA_LO + "00"
                        + constant.REG_CURVE_APPEND + "01" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }

                Delay_ms(16);

                bRx = this.frmain.HexStringToByteArray("FE" + "2D" + "02" + "02" +constant.REG_MODEL + "02"
                    + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02");
                sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "2D" + "02" + "02" + constant.REG_MODEL + "02"
                    + "03" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "04" + "02" + constant.REG_MODEL + "02"
                    + "05" + "0C" + constant.REG_CURVE_POSITION_HI + "01"
                    + constant.REG_CURVE_POSITION_LO + "60" + constant.REG_CURVE_DELTA_HI + "02" + constant.REG_CURVE_DELTA_LO + "00"
                    + constant.REG_CURVE_APPEND + "01" + constant.REG_MODEL + "02"
                    + "06" + "02" + constant.REG_MODEL + "02"
                    + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                if (this.frmain.send_timer.Enabled == true)
                {
                    this.frmain.send_timer.Stop();
                }

                this.frmain.servosend(curve);


                if (this.frmain.realtime_judge == false)
                {
                    this.frmain.send_timer.Stop();
                }
                else if (this.frmain.realtime_judge == true)
                {
                    this.frmain.send_timer.Start();
                }
                #endregion
                Delay_ms(1500);
            }
            
        }      
        private void Robot_movebackBtn_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            string curve = null;
            robot_time.Stop();
            move1_start = false;

            if (Robot_movebackBtn.Text == "机器人倒退（H）")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.REG_MODEL + "02"
                + "02" + "02" + constant.REG_MODEL + "02"
                + "03" + "02" + constant.REG_MODEL + "02"
                + "04" + "02" + constant.REG_MODEL + "02"
                + "05" + "02" + constant.REG_MODEL + "02"
                + "06" + "02" + constant.REG_MODEL + "02"
                + "07" + "02" + constant.REG_MODEL + "02"
                + "08" + "02" + constant.REG_MODEL + "02");
                byte sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.REG_MODEL + "02"
                + "02" + "02" + constant.REG_MODEL + "02"
                + "03" + "02" + constant.REG_MODEL + "02"
                + "04" + "02" + constant.REG_MODEL + "02"
                + "05" + "02" + constant.REG_MODEL + "02"
                + "06" + "02" + constant.REG_MODEL + "02"
                + "07" + "02" + constant.REG_MODEL + "02"
                + "08" + "02" + constant.REG_MODEL + "02" + sum_str;

                Robot_movebackBtn.Text = "机器人停止（H）";
                move2_start = true;
     
                move2timer_function();

            }
            else if (Robot_movebackBtn.Text == "机器人停止（H）")
            {
                byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02");
                byte sum = this.frmain.checksum(bRx);

                if (sum >= 16)
                    sum_str = Convert.ToString(sum, 16);
                else
                    sum_str = "0" + Convert.ToString(sum, 16);
                curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.BRAKE + "02"
                + "02" + "02" + constant.BRAKE + "02"
                + "03" + "02" + constant.BRAKE + "02"
                + "04" + "02" + constant.BRAKE + "02"
                + "05" + "02" + constant.BRAKE + "02"
                + "06" + "02" + constant.BRAKE + "02"
                + "07" + "02" + constant.BRAKE + "02"
                + "08" + "02" + constant.BRAKE + "02" + sum_str;
                Robot_movebackBtn.Text = "机器人倒退（H）";

                move2_start = false;
            }
            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
        private void txtbrake1_Click(object sender, EventArgs e)
        {
            string sum_str = null;
            string curve = null;
            robot_time.Stop();
            move1_start = false;
            move2_start = false;

            byte[] bRx = this.frmain.HexStringToByteArray("FE" + "21" + "01" + "02" + constant.BRAKE + "01"
                + "02" + "02" + constant.BRAKE + "01"
                + "03" + "02" + constant.BRAKE + "01"
                + "04" + "02" + constant.BRAKE + "01"
                + "05" + "02" + constant.BRAKE + "01"
                + "06" + "02" + constant.BRAKE + "01"
                + "07" + "02" + constant.BRAKE + "01"
                + "08" + "02" + constant.BRAKE + "01");
            byte sum = this.frmain.checksum(bRx);

            if (sum >= 16)
                sum_str = Convert.ToString(sum, 16);
            else
                sum_str = "0" + Convert.ToString(sum, 16);
            curve = "FF" + "FF" + "FE" + "21" + "01" + "02" + constant.BRAKE + "01"
                + "02" + "02" + constant.BRAKE + "01"
                + "03" + "02" + constant.BRAKE + "01"
                + "04" + "02" + constant.BRAKE + "01"
                + "05" + "02" + constant.BRAKE + "01"
                + "06" + "02" + constant.BRAKE + "01"
                + "07" + "02" + constant.BRAKE + "01"
                + "08" + "02" + constant.BRAKE + "01" + sum_str;

            if (this.frmain.send_timer.Enabled == true)
            {
                this.frmain.send_timer.Stop();
            }

            this.frmain.servosend(curve);


            if (this.frmain.realtime_judge == false)
            {
                this.frmain.send_timer.Stop();
            }
            else if (this.frmain.realtime_judge == true)
            {
                this.frmain.send_timer.Start();
            }
        }
    }
}
